package cz.fit.dpo.task1.commands;

import cz.fit.dpo.task1.Game;
import cz.fit.dpo.task1.ICommandProvider;
import cz.fit.dpo.task1.Item;
import cz.fit.dpo.task1.exceptions.ItemNotOwnedException;

public class LiftCommand implements ICommand {

	private Item item = null;

	public LiftCommand(Item i) {
		this.item = i;
	}

	@Override
	public boolean execute(Game game, ICommandProvider view) {
		if ( item == null ) {
			view.printInputResult("This item doesn't exist");
		} else {
			try {
				if (game.liftItem(item)) {
					view.printInputResult("You've successfully lifted " +item+" from " + game.getPlayer().isInRoom());
					return true;
				} else {
					view.printInputResult("You can't lift " + item + " from " + game.getPlayer().isInRoom() + " - aren't you too heavy??? Do you think lifting " + item + " is a good idea???");
				}
			} catch (ItemNotOwnedException e) {
				view.printInputResult(item + " is not in " + game.getPlayer().isInRoom());
			}
		}
		return false;
	}
}
